package com.clippick.clipboard;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import co.kr.clippick.R;

import com.clippick.NewMainActivity;
import com.clippick.common.GlobalValue;

public class ShorcutNotificationService extends Service {
	// common
	private Context mContext;

	public void onCreate() {
		super.onCreate();
		mContext = this;
		if (GlobalValue.isShowNotification(mContext))
			showNotification();
	}

	public int onStartCommand(Intent intent, int flags, int startId) {
		super.onStartCommand(intent, flags, startId);
		return START_STICKY;
	}

	@SuppressWarnings("deprecation")
	public void showNotification() {
		Notification notif = new Notification(R.drawable.icon_sub,
				getString(R.string.initiating_shorcut_title),
				System.currentTimeMillis());
		notif.flags |= (Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR);
		Intent intent = new Intent(this, NewMainActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
				| Intent.FLAG_ACTIVITY_CLEAR_TOP
				| Intent.FLAG_ACTIVITY_SINGLE_TOP);

		PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
				intent, 0);
		notif.setLatestEventInfo(this,
				getString(R.string.initiating_shorcut_message),
				getString(R.string.initiating_shorcut_ticker), contentIntent);

		startForeground(1337, notif);

	}

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
}